Skip to content

allow exporting remote collection #2813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 21, 2025

Conversation

imolorhe
Copy link
Collaborator

@imolorhe imolorhe commented Apr 21, 2025

Fixes

#2792

Checks

  • Ran yarn test-build
  • Updated relevant documentations
  • Updated matching config options in altair-static

Changes proposed in this pull request:

Summary by Sourcery

Add support for exporting and managing remote query collections in Altair

Bug Fixes:

  • Fix collection import process to correctly set storage type and workspace for imported collections

Enhancements:

  • Improve collection management by adding support for remote collection storage types
  • Enhance error handling when retrieving collections
  • Update collection retrieval methods to handle remote and local collections

Chores:

  • Update styling for Ant Design buttons to improve visual consistency

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Local collections and their queries now include metadata indicating local storage.
    • Collections can be retrieved whether stored locally or remotely.
  • Bug Fixes

    • Enhanced error handling and logging during collection retrieval to prevent unhandled errors.
  • Style

    • Refined button styles for consistent appearance and improved theming throughout the app.

Copy link

sourcery-ai bot commented Apr 21, 2025

Reviewer's Guide by Sourcery

This pull request allows exporting remote collections. It includes changes to the styling of buttons, adds try-catch block when fetching collections, and ensures that queries in a collection have the correct storage type when a collection is created.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Updated the styling of buttons.
  • Added styling for the default button state.
  • Added styling for the primary button state.
  • Added styling for the focus and hover states of buttons.
packages/altair-app/src/scss/_ant-overrides.scss
Added a try-catch block when fetching a collection.
  • Added a try-catch block to handle errors when fetching a collection.
  • Added logging of errors to the console.
packages/altair-app/src/app/modules/altair/services/api/api.service.ts
Ensured that queries in a collection have the correct storage type when a collection is created.
  • Set the storage type of queries to 'local' when a collection is created.
  • Set the workspace ID to 'LOCAL' when a collection is created.
packages/altair-app/src/app/modules/altair/services/query-collection/query-collection.service.ts
Refactored the getCollectionTreeByCollectionId method to use the getCollectionByID method.
  • Updated the getCollectionTreeByCollectionId method to use the getCollectionByID method.
packages/altair-app/src/app/modules/altair/services/query-collection/query-collection.service.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

coderabbitai bot commented Apr 21, 2025

Walkthrough

The changes introduce improved error handling in the API service by adding a try-catch block to the getCollection method, ensuring errors are logged and handled gracefully. In the query collection service, local collections and their queries are now explicitly marked with a storageType: 'local' property and workspaceId is set to a local constant, enhancing metadata clarity. Additionally, the method for retrieving collection trees is updated to support both local and remote collections. Button styling in the SCSS file is refined, standardizing border-radius and theming for primary and default buttons, and enhancing hover/focus states.

Changes

File(s) Change Summary
packages/altair-app/src/app/modules/altair/services/api/api.service.ts Added try-catch error handling to getCollection method, with error logging and safe undefined returns.
packages/altair-app/src/app/modules/altair/services/query-collection/query-collection.service.ts Added storageType: 'local' and workspaceId metadata to local collections/queries; updated retrieval logic to support both local and remote collections.
packages/altair-app/src/scss/_ant-overrides.scss Updated button styles for .ant-btn and .ant-btn-primary, including border-radius, theming, and interactive states.

Poem

In the warren of code, a rabbit hops,
With safer fetches and stylish button tops.
Local or remote, collections now declare,
Their storage type, with metadata flair.
Buttons gleam in colors true,
Error logs hop into view.
A tidy patch—hip hop hooray!
For Altair’s code, it’s a brighter day! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/altair-app/src/app/modules/altair/services/api/api.service.ts

Oops! Something went wrong! :(

ESLint: 8.18.0

ESLint couldn't find the plugin "@angular-eslint/eslint-plugin".

(The package "@angular-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/packages/altair-app".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install @angular-eslint/eslint-plugin@latest --save-dev

The plugin "@angular-eslint/eslint-plugin" was referenced from the config file in "packages/altair-app/.eslintrc.js#overrides[0]".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a86ad9c and 015177e.

📒 Files selected for processing (1)
  • packages/altair-app/src/app/modules/altair/services/api/api.service.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/altair-app/src/app/modules/altair/services/api/api.service.ts
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: electron / electron (macos-latest)
  • GitHub Check: electron / electron (ubuntu-latest)
  • GitHub Check: electron / electron (windows-latest)
  • GitHub Check: docker / docker
  • GitHub Check: sites / Deploy sites
  • GitHub Check: tests / e2e-test (ubuntu-latest)
  • GitHub Check: tests / api-e2e-test
  • GitHub Check: tests / e2e-test (macos-latest)
  • GitHub Check: tests / test (macos-latest)
  • GitHub Check: tests / test (ubuntu-latest)
  • GitHub Check: build_and_preview

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @imolorhe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request focuses on enhancing the handling of remote query collections within the Altair application. The primary goal is to allow exporting remote collections by addressing error handling and ensuring proper data management. I've added a try-catch block to the getCollection method in api.service.ts to handle potential errors when fetching collections from the server. Additionally, I've updated the QueryCollectionService to ensure that when a collection is added, its queries and the collection itself are explicitly marked with a storageType of 'local' and a workspaceId of WORKSPACES.LOCAL. Finally, I've updated the getCollectionTreeByCollectionId method to use getCollectionByID instead of getLocalCollectionByID to retrieve collections, and made some styling adjustments to the ant design button components.

Highlights

  • Error Handling: Implemented a try-catch block in ApiService.getCollection to gracefully handle errors when fetching remote collections.
  • Data Management: Ensured that new collections and their queries are explicitly marked as 'local' with the appropriate workspaceId in QueryCollectionService.
  • Collection Retrieval: Modified QueryCollectionService.getCollectionTreeByCollectionId to use the generic getCollectionByID method.
  • Styling: Adjusted the styling of the ant design button components.

Changelog

  • packages/altair-app/src/app/modules/altair/services/api/api.service.ts
    • Added a try-catch block to the getCollection method to handle potential errors during remote collection fetching (lines 149-159).
  • packages/altair-app/src/app/modules/altair/services/query-collection/query-collection.service.ts
    • Modified the add method to explicitly set storageType to 'local' and workspaceId to WORKSPACES.LOCAL for new collections (lines 131-132).
    • Added storageType: 'local' to each query in the collection (line 122).
    • Updated getCollectionTreeByCollectionId to use getCollectionByID instead of getLocalCollectionByID (line 705).
  • packages/altair-app/src/scss/_ant-overrides.scss
    • Added styling adjustments to the ant design button components (lines 43-66).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A remote collection's call,
Error's shadow starts to fall,
But code's embrace,
Finds a safer place,
And exports succeed for all.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces the ability to export remote collections, enhancing the application's functionality. The changes include adding error handling to the getCollection method in api.service.ts, modifying the query-collection.service.ts to handle local and remote collections, and updating the styling for buttons in _ant-overrides.scss. Overall, the changes seem well-structured, but there are a few areas that could be improved.

Summary of Findings

  • Error Handling in API Service: The addition of a try-catch block in api.service.ts is good for handling errors when fetching collections. However, consider providing more informative error messages or using a more robust logging mechanism.
  • Redundant storageType assignment: The storageType is being assigned in multiple places in query-collection.service.ts. Consolidate these assignments to reduce redundancy and improve maintainability.
  • CSS Style Overrides: The CSS overrides in _ant-overrides.scss could be more specific to avoid unintended side effects on other components. Consider using more specific class names or nesting the styles within a more specific context.

Merge Readiness

The pull request is almost ready for merging. Addressing the redundant storageType assignments and refining the CSS overrides would improve the code quality. While the error handling is a good addition, consider enhancing the error messages for better debugging. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. I recommend that the author address the comments before merging.


return serverCollectionToLocalCollection(res);
} catch (e) {
console.error(e);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding more context to the error message, such as the collectionServerId, to aid in debugging.

Suggested change
console.error(e);
console.error(`Error fetching collection ${collectionServerId}:`, e);

Comment on lines +120 to +126
return {
...query,
storageType: 'local',
id: uuid(),
created_at: now,
updated_at: now,
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The storageType is being assigned here. It's also assigned later when adding to the storage. Consider consolidating this to avoid redundancy.

      return {
        ...query,
        id: uuid(),
        created_at: now,
        updated_at: now,
      };

Comment on lines 130 to +131
...collection,
storageType: 'local',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The storageType is being assigned here as well. Consider consolidating the storageType assignment to a single location.

      ...collection,
      workspaceId: WORKSPACES.LOCAL,
      id: collectionId ?? uuid(),

Comment on lines +62 to +65
.ant-btn:focus,
.ant-btn:hover {
color: var(--primary-color);
border-color: var(--primary-color);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These styles are quite broad and could potentially affect other buttons in the application unintentionally. Consider using a more specific class or nesting these styles within a more specific context to avoid unintended side effects.

.altair-app .ant-btn:focus,
.altair-app .ant-btn:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
}

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @imolorhe - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a comment explaining why the try-catch block was added in ApiService.getCollection.
  • It looks like you're setting storageType: 'local' in a few places - consider creating a constant for this value to avoid duplication.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

github-actions bot commented Apr 21, 2025

Visit the preview URL for this PR (updated for commit 015177e):

https://altair-gql--pr2813-imolorhe-allow-expor-7qpbocju.web.app

(expires Mon, 28 Apr 2025 12:06:25 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 02d6323d75a99e532a38922862e269d63351a6cf

@imolorhe imolorhe added this pull request to the merge queue Apr 21, 2025
Merged via the queue into master with commit eeb2890 Apr 21, 2025
17 checks passed
@imolorhe imolorhe deleted the imolorhe/allow-export-remote-collection branch April 21, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant